<?php
namespace Admin\Controller;

use Think\Controller;

class BBSinvitController extends Controller
{

	public function index()
	{
		// 得到分页查询的条件
		$map = array();
		if (!empty($_GET['intitle'])) {
			$map['intitle'] = array('LIKE',"%{$_GET['intitle']}%");
		}
		foreach($map as $key=>$val) {
			$Page->parameter[$key] = urlencode($val);
		}
		$iniv = M('invitation');
		$count = $iniv->where($map)->count();// 查询满足要求的总记录数
		$Page = new \Think\Page($count,7);// 实例化分页类 传入总记录数和每页显示的记录数(5)
		// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$data = $iniv->where($map)->limit($Page->firstRow.','.$Page->listRows)->select();
		$show = $Page->show();// 分页显示输出
		$this->assign('page',$show);// 赋值分页输出

		$this->assign('data',$data);
		$this->display('BBSinvit/index');
	}

	public function TypeIndex()
	{
		$type = M('type');
		$fatherMap['fid']= '0';
		$data = $type->where($fatherMap)->select();
		//更改数组，便于HTML页面双重遍历
		foreach ($data as $key => $value) {
			$data[$key]['zilei'] = $type->where("fid={$value['tid']}")->select();
		}
		$this->assign('list',$data);
		$this->display('BBSinvit/TypeIndex');
	}
	public function del()
	{
		$iniv = M('invitation');
		$map['inid'] = array('eq',I('get.inid'));
		
		if(I('get.inid')){
			$iniv->where($map)->delete();
		}
	}
	public function DoAjax()
	{
		$iniv = M('invitation');
		$tid = I('get.tid');
		$data = $iniv->where('pid = '.$tid)->select();
		$this->assign('data',$data);
		$this->display('BBSinvit/AjaxIndex');
	}


}